rdci <- function(dt, alpha=0.05) {
  # Compute the Risk Difference 95% CI
  if(nrow(dt)==2 && ncol(dt)==2){
    a <- dt[1, 1]
    b <- dt[1, 2]
    c <- dt[2, 1]
    d <- dt[2, 2]
    
    p1 <- a / (a + b)
    p2 <- c / (c + d)
    
    q1 <- 1 - p1
    q2 <- 1 - p2
    
    n1 <- a + b
    n2 <- c + d
    
    if (p1 >= p2) {
      tmp1 <- p1-p2 - (1/(2*n1) + 1/(2*n2))
      tmp2 <- qnorm(1-alpha/2) * sqrt(p1*q1/n1+p2*q2/n2)
    } else{
      tmp1 <- p1-p2 + (1/(2*n1) + 1/(2*n2))
      tmp2 <- qnorm(1-alpha/2) * sqrt(p1*q1/n1+p2*q2/n2)
    }
    
    c1 <- tmp1 + tmp2
    c2 <- tmp1 - tmp2
    
    return(sort(c(c1, c2)))
  }else{
    return(0)
  }
}
